/*    */ package bupt.luo.demo.config;
/*    */ 
/*    */ import java.io.IOException;
/*    */ import javax.servlet.Filter;
/*    */ import javax.servlet.FilterChain;
/*    */ import javax.servlet.FilterConfig;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.ServletRequest;
/*    */ import javax.servlet.ServletResponse;
/*    */ import javax.servlet.annotation.WebFilter;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.springframework.stereotype.Component;
/*    */ 
/*    */ @Component
/*    */ @WebFilter(urlPatterns = {"/*"}, filterName = "corsfilter")
/*    */ public class CorsConfig
/*    */   implements Filter
/*    */ {
/*    */   public void init(FilterConfig filterConfig) throws ServletException {}
/*    */   
/*    */   public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
/* 23 */     HttpServletResponse httpResponse = (HttpServletResponse)servletResponse;
/* 24 */     HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest;
/* 25 */     httpResponse.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
/* 26 */     httpResponse.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
/* 27 */     httpResponse.setHeader("Access-Control-Allow-Credentials", "true");
/* 28 */     httpResponse.setHeader("Content-type", "*");
/* 29 */     httpResponse.addHeader("Access-Control-Allow-Origin", "*");
/* 30 */     httpResponse.setHeader("Access-Control-Max-Age", "3600");
/*    */     
/* 32 */     if ("OPTIONS".equals(httpServletRequest.getMethod())) {
/* 33 */       httpResponse.setStatus(200);
/*    */     } else {
/*    */       
/* 36 */       filterChain.doFilter((ServletRequest)httpServletRequest, (ServletResponse)httpResponse);
/*    */     } 
/*    */   }
/*    */   
/*    */   public void destroy() {}
/*    */ }


/* Location:              C:\Users\28293\Desktop\demo-0.0.1-SNAPSHOT\BOOT-INF\classes.zip!\classes\bupt\luo\demo\config\CorsConfig.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */